/**
 * author:龚佳新 date:2013-08-13 
 * 杜邦模型 方法全部抽取 为目前最精简模式
 */
Cnbi.model.Dupont = function(params) {
	Cnbi.model.BaseSliderAndProgress.call(this, params);
	var scope = this, domArray = params["domArray"];
	this.initPage = function() {
		if (!scope.flag) {
			CnbiSoft.setCurrentRenderer("JavaScript");
		}
		setFormula(false);
		scope.setSliderValue(params.slider_array, scope.datas, "Idinput");
		scope.setProgressValue(params.progress_array,scope.datas, "Idspan");
		this.initChart(true);		
	}
	 this.initBefore=function(){
	      for(var i=0;i<scope.zIndicator.length;i++){
			 	var tId = scope["vaprefix"]+scope.zIndicator[i]["id"];
				if(scope.defaults["id"]=="dupont"&& scope.defaults["judgeObj"]&&tId==scope.defaults["judgeObj"]["qtysk"]){
		               var o = {id:0,vaprefix:scope.vaprefix,datas:scope.datas};
		               scope.getDefinedIndicatorObjResult(o,scope.zIndicator[i]);
		               scope.datas[scope.defaults["judgeObj"]["qtysk"]] = o.result;
				}
			}
    }
	this.initChart=function(action){
		    var obj1={domId:domArray[0],datas:scope.datas[params["judgeObj"]["jzcsyv"]]-0,range:industryJ,title:'净资产收益率'},
      		obj2={domId:domArray[1],datas:scope.datas[params["judgeObj"]["zzczzv"]]-0,range:industryZ,title:'总资产周转率'};
    	  if(action)new Cnbi.model.Chart(getAngularGaugeObj(obj1));//-2.5,1.2,5.6,7.8
    	  if(action)new Cnbi.model.Chart(getAngularGaugeObj(obj2));
    	  }
	 function getAngularGaugeObj(params){//caption="'+params["title"]+'"
     	var range = params["range"],
     	dialsAttr=' bgColor="000000,4D4D4D" borderAlpha="0" baseWidth="18" topWidth="1" rearExtension="40" valueY="225" radius="60" ',
        attributes=' manageResize="1" bgAlpha="0" origW="420"  origH="250"  manageValueOverlapping="1" numberSuffix="%" showValue="1" showTickValues="1"  tickValueDistance="-90" tickvaluestep="3" bgColor="FFFFFF" showLimits="15"  lowerLimitDisplay="差" upperLimitDisplay="好" upperLimit="'+range["excellent"]+'" lowerLimit="'+range["lowers"]+'" baseFontColor="000000"  majorTMNumber="11" majorTMColor="2F2E2E"  majorTMHeight="20" majorTMThickness="1.5" minorTMNumber="4" minorTMColor="2F2E2E" minorTMHeight="10" showGaugeBorder="0" gaugeOuterRadius="90" gaugeInnerRadius="60" gaugeOriginX="180" gaugeOriginY="150" gaugeAlpha="50" placeValuesInside="1" toolTipBgColor="FFFFFF" toolTipBorderColor="CCCCCC" gaugeFillMix="" showShadow="0" annRenderDelay="0" pivotRadius="13" pivotFillMix="{E6E6E6},{999999}" pivotBorderColor="bebcb0" pivotFillRatio="70,30" showBorder="0" gaugeStartAngle="230" gaugeEndAngle="-50" ',
     //	attributes='manageResize="1" showValue="1"  origW="330" showBorder="0" origH="170" showTickValues="0" numberSuffix="%" baseFontColor="000000" animation="1" autoAlignTickValues="1"  tickValueDistance="1" bgColor="FFFFFF" bgAlpha="100" lowerLimit="'+range["lowers"]+'" upperLimit="'+range["excellent"]+'" gaugeStartAngle="180" gaugeEndAngle="0" gaugeOuterRadius="-80" gaugeInnerRadius="100" gaugeOriginX="165" gaugeOriginY="130" minorTMNumber="5" majorTMColor="000000" minorTMColor="000000" majorTMHeight="15" majorTMThickness="1" minorTMHeight="10" minorTMThickness="1" decmials="2" placeValuesInside="1" pivotFillMix="87CEFF, 25588A" pivotFillRatio="50,50" pivotBorderThickness="40" pivotBorderColor="CCCCCC" pivotRadius="15" showShadow="0" toolTipBgColor="FFFFFF"',
    	annotations='<annotationGroup x="180" y="150" showBelow="1">\n\
			<annotation  type="circle" x="0" y="0" radius="115" fillColor="35BADC,35BDDF, C5F4FF"  fillRatio="70,20, 10" borderColor="35BADC" />\n\
			<annotation type="circle" x="0" y="0" radius="100" fillColor="FFFFFF, FFFFFF" fillRatio="20,80" borderColor="FFFFFF" />\n\
			<annotation type="circle" x="0" y="0" radius="100"  fillColor="E6E6E6, FFFFFF" fillAlpha="50" borderColor="E6E6E6" />\n\
		</annotationGroup>',
		  trendpoints='<point startValue="'+range["lowers"]+'" endValue="'+range["average"]+'" valueInside="1" color="FF0000" innerRadius="0" alpha="100" />' +
      			  '<point startValue="'+range["average"]+'" endValue="'+range["good"]+'" valueInside="0" color="EEC900" innerRadius="0" alpha="100" />' +
      			  '<point startValue="'+range["good"]+'" endValue="'+range["excellent"]+'" valueInside="0" color="00CD00" innerRadius="0" alpha="100" />',

      styles='<definition><style type="font" name="a" bgColor="FF0000" size="14" borderColor="FF0000"  baseFontColor="FF0000" /><style name="MyFirstBevel" type="Bevel" /></definition><application><apply toObject="Value" styles="a"/><apply toObject="Value" styles="MyFirstBevel"/></application>';
      return {chartType:0,//图表类型 ：0为单值数据图表;1为多单数据图表;2为多系数据图表
	            swfName:"AngularGauge",//这个就不用说了吧！  //AngularGauge.swf
	            datas:params["datas"],//显示的数据  注意：规定的数据解析格式  numberSuffix="%"
	            domId:params["domId"],//渲染的dom节点
	            attributes:attributes,
	            color:["FF0000","EEC900","00CD00"], //颜色good 
	            dialsAttr:dialsAttr,
	          //  trendpoints:trendpoints,
	            styles:styles,
	            annotations:annotations,
	          	colorRange:[range["lowers"],range["average"],range["good"],range["excellent"]],//chartType==0时才有此属性
	          	width:290,height:240};
    };
	this.updataInputAfter=function(id ,value,datas ){
		if(id.indexOf("Id")!=-1){
		  id = id.split("Id")[0];
		}
		if(id==params["judgeObj"]["yysr"]){//cnbi1113pro_Idspan    --cnbi1113pro1Idspan
			//  alert(params["judgeObj"]["yysr"]+"---");
		     scope.updataSpanAndProgess(id+params["doubleUIFlag"]+"1_Idspan");
		     scope.updataSpanAndProgess(id+params["doubleUIFlag"]+"2_Idspan");
		}else if(id==params["judgeObj"]["sds"]){
		
		}else{
			scope.updataSpanAndProgess(id+params["doubleUIFlag"]+"_Idspan");
		}
		setFormula(true);   
	};
	/**
	 * 设置所有公式值  114010
	 */
	function setFormula(action) {
		var zzczzv = params["judgeObj"]["zzczzv"],jzcsyv = params["judgeObj"]["jzcsyv"];
	   var o = {id:0,vaprefix:scope.vaprefix,datas:scope.datas};
		 o["id"]=70;
		 scope.getIndicatorResult(o);
		 zzczzv = zzczzv.replaceAll(o["vaprefix"],"");
	     jzcsyv = jzcsyv.replaceAll(o["vaprefix"],"");
		var  chartId=domArray[1].toString()+domArray[2].toString();
	       if(getChartFromId(chartId)){
	         getChartFromId(chartId).setData(1,scope.datas[o["vaprefix"]+zzczzv]);
	       }
	       
	  	 chartId=domArray[0].toString()+domArray[2].toString();
	  	 if(getChartFromId(chartId)){
	  	    getChartFromId(chartId).setData(1, scope.datas[o["vaprefix"]+jzcsyv]);
			}
		      
	}

	scope.init();
}